<!DOCTYPE html>
<html>
	<head>
		<title>益多多回收</title>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<link rel="stylesheet" href="${s.base}/mobile/newcss/weui.min.css">
		<link rel="stylesheet" href="${s.base}/mobile/newcss/jquery-weui.css">
		<link rel="stylesheet" href="${s.base}/mobile/newcss/base.css?123456">
		<link rel="stylesheet" href="${s.base}/mobile/newcss/component.css?1234545454">
	</head>
	<style type="text/css">
		.no-select{
			color: #999999
		}
		.icon-zhengque {
			width: 50px; height: 30px;
			vertical-align: -0.15em;
			overflow: hidden;
			color:#f00;
		}
		.icon-address {
			width: 16px; height: 16px;
			vertical-align: -0.15em;
			overflow: hidden;
			color:#f00;
		}
		.weui-cell{padding:0px 0px;}
		.weui-cells_checkbox .weui-check:checked+.weui-icon-checked:before{
			color:#FF5353;}
		[class*=" weui-icon-"], [class^=weui-icon-]{line-height:30px;}
		[class*=" weui-icon-"]:before, [class^=weui-icon-]:before{margin-left:0px;margin-right:0px;}
		.weui-cells_checkbox .weui-icon-checked:before {font-size: 16px; display: block;}
		.xyg-address{width:90%; padding:5px 5%; background:#ffffff; margin:5px 0px;}
		.xyg-address .xyg-address-name{width:80%; float:left;}
		.xyg-address .xyg-address-icon{width:20%; float:left; text-align:right; font-size:20px; color:#F00; font-weight:bold; line-height:40px;}
		.xyg-address .xyg-address-icon a{ display:block; width:60px; height:26px;text-align:center; font-size:14px; color:#D4D4D4; font-weight:normal; line-height:26px; border-radius:13px; border:1px solid #D4D4D4; letter-spacing:1px;}
		.xyg-address .xyg-address-name .xyg-address-name-content{width:100%; height:30px; line-height:30px; font-size:14px; font-weight:bold;}
		.xyg-address .xyg-address-name .xyg-address-name-content .xyg-address-name-phone{font-size:14px; font-weight:normal;}
		.xyg-address .xyg-address-name .xyg-address-name-desc{width:100%; height:auto; line-height:20px; font-size:14px; color:#999999; padding:5px 0px; letter-spacing:1px;}
		.xyg-address .xyg-address-bottom{width:100%;}
		.xyg-address .xyg-address-bottom .xyg-address-bottom-left{width:50%; float:left;font-size:12px; color:#FF5353;line-height:30px; height:30px;}
		.xyg-address .xyg-address-bottom .xyg-address-bottom-right{width:50%; float:left;font-size:12px; color:#999999;line-height:30px; height:30px; text-align:right; }
		.xyg-no-select{color:#999999;}
		.xyg-address-footer{width: 100%;height:40px; line-height:40px; text-align:center; background: #069AFE; position: fixed;bottom: 0px;left: 0px; padding:5px 0px;font-size:16px; letter-spacing:1px; letter-spacing:0.5px; color:#fff; }
	</style>
	<body style="background:#F8F8F8;">
	<!--地址管理开始-->
	<#list addressList as address>
	<div class="xyg-address">
		<div class="xyg-address-name">
			<div class="xyg-address-name-content">
				${address.linkName}&nbsp;&nbsp;<span class="xyg-address-name-phone">${address.phone}</span>
			</div>
			<div class="xyg-address-name-desc">
				<#if address.doorType == '1'>
					${address.building}幢${address.unit}单元${address.room}室
				<#else>
					${address.descripts}
				</#if>
			</div>
		</div>
		<#if status=='1' || status=='2' || status == '3'>
			<div class="xyg-address-icon">
				<!--<svg class="icon-zhengque" aria-hidden="true">
                  <use xlink:href="#icon-zhengque"></use>
                </svg>-->
				<a href="javascript:void(0)">使用</a>
			</div>
		</#if>

		<div class="clearBoth"></div>
		<div class="xyg-address-bottom">
			<div class="xyg-address-bottom-left weui-cells_checkbox">
				<label class="weui-cell weui-check__label" >
					<div class="weui-cell__hd">
						<input type="radio" class="weui-check" value="${address.id}" name="addressType" <#if address.type?if_exists&&address.type=='1'>checked</#if> >
						<i class="weui-icon-checked"></i>
					</div>
					<div class="weui-cell__bd">
						<p <#if address.type?if_exists&&address.type!='1'>class="no-select"</#if>>已设为默认</p>
					</div>
				</label>
			</div>
			<div class="xyg-address-bottom-right">
            	<span class="xyg-address-bottom-right-icon" onclick="goShopAddressEditPage('${memberId}','${address.id}','1')">
                	<span>
                    	<svg class="icon-address" aria-hidden="true">
						  <use xlink:href="#icon-bianji"></use>
						</svg>
                    </span>
                    编辑
                </span>
				&nbsp;
				<span class="xyg-address-bottom-right-icon" onclick="delAddress('${memberId}','${address.id}')">
                	<span>
                    	<svg class="icon-address" aria-hidden="true">
						  <use xlink:href="#icon-delete"></use>
						</svg>
                    </span>
                    删除
                </span>
			</div>
			<div class="clearBoth"></div>
		</div>
	</div>
	</#list>
	<!--地址管理结束-->

	<!--底部开始-->
	<div class="xyg-address-footer" onclick="goShopAddressAddPage('${memberId}','1')">
		添加地址
	</div>
	<!--底部结束-->
	</body>
	<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
	<script src="${s.base}/mobile/newjs/jquery-2.1.4.js?12132"></script>
	<script src="${s.base}/mobile/newjs/jquery-weui.js?12132"></script>
	<script src="${s.base}/mobile/newjs/swiper.js?12132"></script>
	<script src="${s.base}/mobile/fonts/iconfont.js?12132"></script>
	<script src="${s.base}/mobile/js/base.js?1234545454"></script>
	<!--js分享代码开始-->

	<input type="hidden" value="${jSTicketShareResponse.appid}" id="appid" />
	<input type="hidden" value="${jSTicketShareResponse.fxTitle}" id="fxTitle" />
	<input type="hidden" value="${jSTicketShareResponse.fxImgUrl}" id="fxImgUrl" />
	<input type="hidden" value="${jSTicketShareResponse.fxDesc}" id="fxDesc" />
	<input type="hidden" value="${jSTicketShareResponse.fxUrl}" id="fxUrl" />
	<input type="hidden" value="${jSTicketShareResponse.nonceStr}" id="nonceStr" />
	<input type="hidden" value="${jSTicketShareResponse.timestamp}" id="timestamp" />
	<input type="hidden" value="${jSTicketShareResponse.signature}" id="signature" />
	<script src="${s.base}/mobile/js/share.js"></script>

	<script>
        var memberId = '${memberId}';
        var status = '${status}';

        $('input[type=radio][name=addressType]').change(function() {
            // 设置当前为默认
            var addressId = $(this).val();
            //alert(addressId);
            $.confirm("您确定要设置该地址为默认地址吗？", "设置提示", function() {
                $.showLoading("正在提交中");
                $.ajax({
                    type: "POST",
                    url: "/phone/setAddressDefault?memberId="+memberId+"&addressId="+addressId,
                    success: function(result){
                        if(0==result.code){
                            $.hideLoading();
                            // 移除其他
                            $(".weui-cell__bd p").addClass("no-select");
                            $(this).parent().parent().find("p").removeClass("no-select");
                            $.toast("设置成功", "text");
                            // 刷新当前页面
                            if(status=="1"){
                                $.alert("提交成功",function () {
                                    goShopAddressListPage(memberId,status);
                                });
                            }
                        }else{
                            $.hideLoading();
                            $.alert(result.msg);
                        }
                    },
                    error: function(result){
                        $.hideLoading();
                        $.alert(result.msg,function () {
                            // 刷新当前页面
                            if(status=="1"){
                                goShopAddressListPage(memberId,status);
                            }
                        });
                    }
                });
            }, function() {
                //取消操作
                //$(this).removeAttr("checked");
                // 刷新当前页面
                if(status=="1"){
                    goShopAddressListPage(memberId,status);
                }
            });
        });

        function delAddress(memberId,addressId) {
            $.confirm("您确定要删除该地址吗？", "删除提示", function() {
                $.showLoading("正在提交中");
                $.ajax({
                    type: "POST",
                    url: "/phone/delAddressEntity?memberId="+memberId+"&addressId="+addressId,
                    success: function(result){
                        if(0==result.code){
                            $.hideLoading();
                            $.alert("删除成功",function () {
                                // 刷新当前页面
                                if(status=="1"){
                                    goShopAddressListPage(memberId,status);
                                }
                            });
                        }else{
                            $.hideLoading();
                            $.alert(result.msg);
                        }
                    },
                    error: function(result){
                        $.hideLoading();
                        $.alert(result.msg);
                    }
                });
            }, function() {
                //取消操作
                //$(this).removeAttr("checked");
            });
        }
	</script>
</html>
